﻿@model MerchantTribeStore.Models.ProductPageViewModel
<div id="productpage">    
    @Html.Raw(Model.BreadCrumbsFinal)
    @Html.Raw(Model.PreColumn)    
    <div class="productpagemain">
        <div class="imagecolumn">
            <div class="productimage">
                <img itemprop="image" id="imgMain" src="@Model.MainImageUrl" alt="@Model.MainImageAltText" />
                <input type="hidden" id="imgMainLast" value="" />
            </div>
            @Html.Raw(Model.PreRenderedImages)
        </div>
        <div class="actioncolumn">
            <h1 itemprop="name">
                <span>@Model.LocalProduct.ProductName</span></h1>
            @Html.Raw((string)TempData["messages"])
            <span id="sku" itemprop="productID">@Model.LocalProduct.Sku</span> <span class="stockdisplay">@Html.Raw(Model.StockMessage)</span>
            <div id="productcontrols">
                <form action="@Url.Content("~/" + Model.LocalProduct.UrlSlug)" method="post">
                @Html.Raw(Model.PreRenderedOptions)
                <div id="pricewrapper">@Html.Raw(Model.PreRenderedPrices)</div>
                <label for="quantityfield">
                    Quantity</label>
                <span class="choice">
                    @if (Model.IsAvailableForSale)
                    {
                        <input type="text" name="qty" value="@Model.InitialQuantity" class="forminput short" />
                    }
                </span>
                <div id="localmessage">
                    @Html.Raw(Model.ValidationMessage)
                </div>
                <div class="buttons">
                    @if (Model.IsAvailableForSale)
                    {
                        <input id="addtocartbutton" type="image" src="@ViewBag.AddToCartButtonUrl" alt="Add To Cart" />                            
                        if (Model.IsAvailableForWishList)
                        {
                           <text><br />&nbsp;<br /></text>
                           <input id="savelaterbutton" name="savelaterbutton" type="image" src="@ViewBag.SaveLaterButton" alt="Save For Later" value="SaveLater" />
                        }
                    }
                </div>

                @if (ViewBag.UseFaceBook == true)
                {
                    
                    @Html.Partial("~/views/shared/_FaceBookLike.cshtml",
                        new MerchantTribeStore.Models.FaceBookLikeModel() { PageUrl = ViewBag.CurrentUrl })                
                }
                @if (ViewBag.UseTwitter == true)
                {
                    @Html.Partial("~/views/shared/_Twitter.cshtml",
                        new MerchantTribeStore.Models.TwitterViewModel()
                        {
                            DisplayUrl = ViewBag.CurrentUrl,
                            LinkUrl = ViewBag.CurrentUrl,
                            ViaTwitterName = ViewBag.TwitterHandle,
                            DefaultText = String.Format(ViewBag.TwitterDefaultTweetText, Model.LocalProduct.ProductName + " " + Model.LocalProduct.Sku)
                        })
                }
                @if (ViewBag.UseGooglePlus == true)
                {
                    @Html.Partial("~/views/shared/_GooglePlusOne.cshtml",
                        new MerchantTribeStore.Models.GooglePlusOneViewModel()
                        {
                            PageUrl = ViewBag.CurrentUrl,
                            CountPosition = MerchantTribeStore.Models.GooglePlusOneCountPosition.Inline,
                            Size = MerchantTribeStore.Models.GooglePlusOneSize.Standard                            
                        });
                    
                }

                <input type="hidden" id="productbvin" name="productbvin" value="@Model.LocalProduct.Bvin" />
                <input type="hidden" id="lineitemid" name="lineitemid" value="@Model.LineItemId" />
                <!--VOLUME DISCOUNTS HERE-->
                <div class="clear">
                </div>
                </form>
            </div>
            <div class="productdescription" itemprop="description">
            @Html.Raw(Model.LocalProduct.LongDescription)
            </div>     
            @Html.Raw(Model.SwatchHtml)
            @Html.Raw(Model.PreRenderedTypeValues)                  
        </div>
        <div class="clear">
            &nbsp;</div>
    </div>
    <div class="informationcolumn">
        <ul class="tabnavigation">
            @if (Model.LocalProduct.Reviews.Count > 0 || Model.LocalProduct.AllowReviews)
            {
                <li id="TabNavReviews"><a href="#tabreviews">Reviews</a></li>
            }
            <li id="TabNavSuggested"><a href="#tabsuggesteditems">@ViewBag.RelatedItemsTitle</a></li>
            @foreach (MerchantTribe.Commerce.Catalog.ProductDescriptionTab t in Model.LocalProduct.Tabs.OrderBy(y => y.SortOrder))
            {
                <li id="@("TabNav" + t.Bvin)"><a href="@("#Tab" + t.Bvin)">@t.TabTitle</a></li>
            }
        </ul>
        <div class="tabs">            
            <div id="tabreviews">
                <div class="padded">
                    <h2>
                        Reviews</h2>
                    <div class="reviews">
                        <div class="reviewlist">
                            @Html.Action("TopReviews", "ProductReviews", new { howMany = 3, reviews = Model.LocalProduct.ReviewsApproved })
                            @if (Model.LocalProduct.Reviews.Count > 0)
                            {
                                <div class="ProductReviewLinks">
                                <a href="@Url.Content("~/Products/Reviews/" + Model.LocalProduct.UrlSlug)">View All
                                    Reviews</a><br />
                                </div>
                            }
                        </div>                    
                        <div class="reviewform">
                            @if (Model.LocalProduct.AllowReviews)
                            {                            
                                <h3>
                                    Write a Review for this Product</h3>
                                <div id="submitreviewmessage"></div>
                                <form action="@Url.Content("~/productreviews/create")" method="post" id="submitreviewform">
                                <table class="formtable">
                                <tr>
                                    <td class="formlabel" valign="top" align="right">
                                        Rating
                                    </td>
                                    <td>
                                        <select name="rating">
                                            <option value="5" selected="selected">5 Stars</option>
                                            <option value="4">4 Stars</option>
                                            <option value="3">3 Stars</option>
                                            <option value="2">2 Stars</option>
                                            <option value="1">1 Star</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="formlabel" valign="top" align="right">
                                        Your Review
                                    </td>
                                    <td>
                                        <textarea name="newreview" class="forminput" rows="6" cols="30"></textarea>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="formlabel">
                                        &nbsp;
                                    </td>
                                    <td>
                                        <input type="image" src="@ViewBag.SubmitButtonUrl" alt="Submit" id="submitreviewbutton" />
                                    </td>
                                </tr>
                            </table>
                                <input type="hidden" name="productbvin" value="@Model.LocalProduct.Bvin" />
                            </form>
                            }
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                </div>
            </div>
            <div id="tabsuggesteditems">
                <div class="padded">
                    <h2>@ViewBag.RelatedItemsTitle</h2>
                    <div class="relateditems">
                        @foreach (var item in Model.RelatedItems)
                        {
                            @Html.Partial("RenderSingleProduct", item);
                        }
                        <div class="clear">
                        </div>
                    </div>
                </div>
            </div>
            @foreach (MerchantTribe.Commerce.Catalog.ProductDescriptionTab t in Model.LocalProduct.Tabs.OrderBy(y => y.SortOrder))
            {                                
                <div id="@("Tab" + t.Bvin)">
                    <div class="padded">
                        <h2>@t.TabTitle</h2>
                        @Html.Raw(t.HtmlData)
                    </div>
                </div>
            }
        </div>
    </div>
    @Html.Raw(Model.PostColumn)    
</div>
<div class="modal2">
    <div class="popoverframe2">
        <a id="dialogclose" href="#">Close</a><br />
        <iframe id="popoverpage2"></iframe>
        <br />
        <a id="dialogclose2" href="#">Close</a>
    </div>
</div>
